<template>
  <el-container>
    <!-- aside -->
    <el-aside :width="width">
      <h1 class="logo"></h1>
      <el-menu
        class="el-menu"
        ref="sideMenu"
        :collapse="isCollapse"
        :default-active="$route.path"
        active-text-color="rgb(228, 120, 51)"
      >
        <qf-sub-menu :sideMenu="sideMenu"></qf-sub-menu>
      </el-menu>
      <!-- <el-row class="tac">
        <el-col :span="12">
         
          <el-menu
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @close="handleClose"
          >
            <el-menu-item index="1" @click="to1">
              <i class="iconfont icon-yemian-copy-copy"></i>
              <span slot="title">管理首页</span>
            </el-menu-item>
            <el-submenu index="2">
              <template slot="title">
                <i class="iconfont icon-icon-"></i>
                <span>学员管理</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="2-1">
                  <i class="iconfont icon-xiangmuguanli"></i
                  >学员项目管理</el-menu-item
                >
                <el-menu-item index="2-2">
                  <i class="iconfont icon-read"></i>学员资料</el-menu-item
                >
                <el-menu-item index="2-3">
                  <i class="iconfont icon-sushe"></i>学员宿舍</el-menu-item
                >
              </el-menu-item-group>
            </el-submenu>
            <el-menu-item index="3" @click="to2">
              <i class="iconfont icon-kaoqin1"></i>
              <span slot="title">考勤管理</span>
            </el-menu-item>
            <el-menu-item index="4">
              <i class="iconfont icon-shuju"></i>
              <span slot="title">数据统计</span>
            </el-menu-item>
            <el-menu-item index="5">
              <i class="iconfont icon-Icon_wode1-copy-copy"></i>
              <span slot="title">我的中心</span>
            </el-menu-item>
          </el-menu>
        </el-col>
      </el-row> -->
    </el-aside>
    <el-container>
      <!-- 顶栏 -->
      <el-header>
        <el-row
          type="flex"
          class="row-bg"
          justify="space-between"
          align="center"
        >
          <el-col :span="6"
            ><div class="grid-content bg-left">
              <i
                @click="open"
                :class="[
                  'iconfont',
                  isCollapse ? 'icon-zhankai5' : ' icon-shouqi',
                ]"
              ></i></div
          ></el-col>
          <el-col :span="6"
            ><div class="grid-content bg-center">
              <h1>千锋管理系统</h1>
            </div></el-col
          >
          <el-col :span="6"
            ><div class="grid-content bg-right">
              <el-avatar :size="40" :src="circleUrl"></el-avatar>
              <div>
                <b>欢迎您:{{ userInfo.nickname }}</b>
                <i @click="quit">退出</i>
              </div>
            </div></el-col
          >
        </el-row>
      </el-header>
      <!-- 主体部分 -->
      <el-main>
        <el-breadcrumb separator-class="el-icon-arrow-right">
          <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
          <el-breadcrumb-item
            :to="{ name: br.name }"
            v-for="br in bread"
            :key="br.name"
            >{{ br.meta.name }}</el-breadcrumb-item
          >
        </el-breadcrumb>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>
<script>
// import * as api from "../../api";
import { mapState } from "vuex";
export default {
  computed: {
    ...mapState(["userInfo", "sideMenu", "bread"]),
    circleUrl() {
      return this.userInfo.headimgurl
        ? this.userInfo.headimgurl
        : "https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png";
    },
  },
  data() {
    return {
      isCollapse: false,
      width: "200px",
    };
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    open() {
      this.isCollapse = !this.isCollapse;
      console.log(this.isCollapse);
      if (this.isCollapse) {
        this.width = "65px";
      } else {
        this.width = "200px";
      }
    },
    quit() {
      localStorage.removeItem("qf-token");
      this.$router.push("/login");
      // location.reload();
    },
  },
};
</script>
<style scoped lang="less">
.el-header {
  background: linear-gradient(135deg, #4c67ff, #5635df);
  color: #fff;
  text-align: center;
  .el-row {
    margin-bottom: 20px;
    &:last-child {
      margin-bottom: 0;
    }
  }
  .el-col {
    border-radius: 4px;
  }
  .bg-left {
    text-align: left;
    vertical-align: middle;
    line-height: 40px;
    .iconfont {
      display: inline-block;
      font-size: 30px;
      color: #fff;
      cursor: pointer;
      line-height: 60px;
      z-index: 9;
    }
  }
  .bg-center {
    h1 {
      color: #fff;
      font-size: 16px;
      font-family: "Mscrosoft yahei";
      line-height: 60px;
    }
  }
  .bg-right {
    text-align: left;
    font-size: 16px;
    font-family: "Mscrosoft yahei";
    position: relative;
    span {
      position: absolute;
      top: 10px;
    }
    div {
      position: absolute;
      top: 20px;
      left: 42px;
      b {
        color: #fff;
      }
      i {
        color: #ff69b4;
        cursor: pointer;
        margin-left: 10px;
        text-decoration: underline;
      }
    }
  }
  .grid-content {
    border-radius: 4px;
    min-height: 60px;
  }
  .row-bg {
    background: linear-gradient(135deg, #4c67ff, #5635df);
    min-height: 60px;
  }
}

.el-aside {
  background: linear-gradient(135deg, #4c67ff, #5635df);
  color: #333;
  text-align: center;
  width: 200px;
  .logo {
    width: 100%;
    min-height: 60px;
    background: linear-gradient(135deg, #4c67ff, #5635df);
    background-image: url(../../assets/images/logo1.png);
    background-size: 80%;
    background-repeat: no-repeat;
    background-position: 50%;
  }

  .el-menu {
    border-right: solid 1px #e6e6e6;
    list-style: none;
    position: relative;
    margin: 0;
    padding-left: 0;
    background-color: #fff;
    width: 100%;
    height: 500px;
    font-size: 14px;
    font-family: "Mscrosoft yahei";
    color: rgb(78, 91, 248);
    // .is-active {
    //   color: rgb(228, 120, 51) !important;
    // }
    /deep/.el-menu-item {
      padding: 0 20px;
      cursor: pointer;
      transition: border-color 0.3s, background-color 0.3s, color 0.3s;
      box-sizing: border-box;
      text-align: left;
      color: rgb(78, 91, 248);
      i {
        margin-right: 10px;
        font-size: 20px;
        color: inherit;
      }
    }
    /deep/.el-submenu__title {
      text-align: left;
      color: rgb(78, 91, 248);
      i {
        margin-right: 10px;
        font-size: 20px;
        color: inherit;
      }
      /deep/ .el-menu-item--inline {
        .el-menu-item {
          padding: 0 0 0 30px;
        }
      }
    }
  }
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  .is-link {
    font-family: "Microsoft yahei";
    font-size: 14px;
  }
  .el-table {
    text-align: center;
    margin-top: 20px;
    /deep/.cell {
      text-align: center;
    }
  }
}

.el-container {
  margin-bottom: 40px;
  height: 681px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
</style>
